package com.lunimei.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.lunimei.container.CatalinaContainer;
import com.lunimei.utils.MLog;

public class StopServerServlet extends HttpServlet implements Servlet {
	private static final String TAG = "StopServerServlet";

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		MLog.i(TAG, "stop server");

		PrintWriter out = resp.getWriter();
		out.write("Server will be stopped.");
		out.flush();

		CatalinaContainer.getInstance().stop();
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}

}
